package top.zhangjianyong.tools.user;

import top.zhangjianyong.tools.entity.stock.StockUser;

import java.util.Arrays;
import java.util.List;

/**
 * @author zhangjianyong
 * @since 2025/3/24 下午3:29
 */
public class StockUserChecker implements UserChecker {


    private final static List<String> IGNORE_URI =
            Arrays.asList(
                    "/stock/user/login",
                    "/stock/user/reg");
    private final static List<String> URI =
            Arrays.asList(
                    "/stock/user", "/stock");

    @Override
    public boolean doCheck(String uri) {
        if (URI.stream().noneMatch(uri::startsWith)) return false; //stock用户仅能访问部分地址
        if (IGNORE_URI.stream().anyMatch(uri::startsWith)) return true; //非登陆允许访问的地址
        IUser user = UserHolder.user(StockUser.class); //判断用户是否登录
        return user != null;
    }
}
